﻿using System.Collections.Generic;
using TheCell;

namespace SudoCalc
{
    class FiltrationUtils
    {
        #region The id of the cell with multiple possibilities in the filter area
        /// <summary>
        /// 过滤区域内拥有多个可能性的cell的id
        /// </summary>
        /// <param name="Zone"></param>
        /// <returns></returns>
        public static Dictionary<int, List<int>> Filtration(Dictionary<int, List<Cell>> Zone)
        {
            Dictionary<int, List<int>> filtration = new Dictionary<int, List<int>>();
            foreach (KeyValuePair<int, List<Cell>> item in Zone)
            {
                List<int> onlyCellId = FilterWithMultiPlepossibilitiesCell(item.Value);
                filtration.Add(item.Key, onlyCellId);
            }
            return filtration;
        }
        #endregion

        #region Filter with multiple possibilities Cell
        /// <summary>
        /// 过滤拥有多个可能性的Cell的ID
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private static List<int> FilterWithMultiPlepossibilitiesCell(List<Cell> item)
        {
            List<int> passibleid = new List<int>();
            foreach (Cell cell in item)
            {
                if (cell.Possible.Count > 1)
                {
                    passibleid.Add(cell.Id);
                }
            }
            return passibleid;
        }
        #endregion
    }
}
